<?php /* Smarty version 2.6.20, created on 2011-11-28 23:51:30
         compiled from C:%5CD%5Cprestashop/modules/blocksearch/blocksearch-top.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'htmlentities', 'C:\\D\\prestashop/modules/blocksearch/blocksearch-top.tpl', 35, false),array('modifier', 'stripslashes', 'C:\\D\\prestashop/modules/blocksearch/blocksearch-top.tpl', 35, false),array('function', 'l', 'C:\\D\\prestashop/modules/blocksearch/blocksearch-top.tpl', 36, false),)), $this); ?>

<!-- Block search module TOP -->
<div id="search_block_top">

	<form method="get" action="<?php echo $this->_tpl_vars['link']->getPageLink('search.php'); ?>
" id="searchbox">
		<p>
			<label for="search_query_top"><!-- image on background --></label>
			<input type="hidden" name="orderby" value="position" />
			<input type="hidden" name="orderway" value="desc" />
			<input class="search_query" type="text" id="search_query_top" name="search_query" value="<?php if (isset ( $_GET['search_query'] )): ?><?php echo ((is_array($_tmp=((is_array($_tmp=$_GET['search_query'])) ? $this->_run_mod_handler('htmlentities', true, $_tmp, $this->_tpl_vars['ENT_QUOTES'], 'utf-8') : htmlentities($_tmp, $this->_tpl_vars['ENT_QUOTES'], 'utf-8')))) ? $this->_run_mod_handler('stripslashes', true, $_tmp) : stripslashes($_tmp)); ?>
<?php endif; ?>" />
			<input type="submit" name="submit_search" value="<?php echo smartyTranslate(array('s' => 'Search','mod' => 'blocksearch'), $this);?>
" class="button" />
	</p>
	</form>
</div>
<?php if ($this->_tpl_vars['instantsearch']): ?>
	<script type="text/javascript">
	// <![CDATA[
		<?php echo '
		function tryToCloseInstantSearch() {
			if ($(\'#old_center_column\').length > 0)
			{
				$(\'#center_column\').remove();
				$(\'#old_center_column\').attr(\'id\', \'center_column\');
				$(\'#center_column\').show();
				return false;
			}
		}
		
		instantSearchQueries = new Array();
		function stopInstantSearchQueries(){
			for(i=0;i<instantSearchQueries.length;i++) {
				instantSearchQueries[i].abort();
			}
			instantSearchQueries = new Array();
		}
		
		$("#search_query_top").keyup(function(){
			if($(this).val().length > 0){
				stopInstantSearchQueries();
				instantSearchQuery = $.ajax({
				url: \''; ?>
<?php if ($this->_tpl_vars['search_ssl'] == 1): ?><?php echo $this->_tpl_vars['link']->getPageLink('search.php',true); ?>
<?php else: ?><?php echo $this->_tpl_vars['link']->getPageLink('search.php'); ?>
<?php endif; ?><?php echo '\',
				data: \'instantSearch=1&id_lang='; ?>
<?php echo $this->_tpl_vars['cookie']->id_lang; ?>
<?php echo '&q=\'+$(this).val(),
				dataType: \'html\',
				success: function(data){
					if($("#search_query_top").val().length > 0)
					{
						tryToCloseInstantSearch();
						$(\'#center_column\').attr(\'id\', \'old_center_column\');
						$(\'#old_center_column\').after(\'<div id="center_column">\'+data+\'</div>\');
						$(\'#old_center_column\').hide();
						$("#instant_search_results a.close").click(function() {
							$("#search_query_top").val(\'\');
							return tryToCloseInstantSearch();
						});
						return false;
					}
					else
						tryToCloseInstantSearch();
					}
				});
				instantSearchQueries.push(instantSearchQuery);
			}
			else
				tryToCloseInstantSearch();
		});
	// ]]>
	'; ?>

	</script>
<?php endif; ?>

<?php if ($this->_tpl_vars['ajaxsearch']): ?>
	<script type="text/javascript">
	// <![CDATA[
	<?php echo '
		$(\'document\').ready( function() {
			$("#search_query_top")
				.autocomplete(
					\''; ?>
<?php if ($this->_tpl_vars['search_ssl'] == 1): ?><?php echo $this->_tpl_vars['link']->getPageLink('search.php',true); ?>
<?php else: ?><?php echo $this->_tpl_vars['link']->getPageLink('search.php'); ?>
<?php endif; ?><?php echo '\', {
						minChars: 3,
						max: 10,
						width: 500,
						selectFirst: false,
						scroll: false,
						dataType: "json",
						formatItem: function(data, i, max, value, term) {
							return value;
						},
						parse: function(data) {
							var mytab = new Array();
							for (var i = 0; i < data.length; i++)
								mytab[mytab.length] = { data: data[i], value: data[i].cname + \' > \' + data[i].pname };
							return mytab;
						},
						extraParams: {
							ajaxSearch: 1,
							id_lang: '; ?>
<?php echo $this->_tpl_vars['cookie']->id_lang; ?>
<?php echo '
						}
					}
				)
				.result(function(event, data, formatted) {
					$(\'#search_query_top\').val(data.pname);
					document.location.href = data.product_link;
				})
		});
	'; ?>

	// ]]>
	</script>
<?php endif; ?>
<!-- /Block search module TOP -->